/* Light Mode Variables */
:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --background: #ffffff;
    --surface: #f8fafc;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --sidebar-width: 260px;
    --chat-width: 380px;
    --column-gap: 16px;
    --app-background: #f1f5f9;
    --loading-overlay-bg: rgba(255, 255, 255, 0.9);
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --primary-color: #3b82f6;
    --secondary-color: #94a3b8;
    --success-color: #22c55e;
    --warning-color: #fbbf24;
    --error-color: #f87171;
    --background: #1e293b;
    --surface: #334155;
    --surface-hover: #475569;
    --border: #475569;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --app-background: #0f172a;
    --loading-overlay-bg: rgba(15, 23, 42, 0.95);
}

/* Auto dark mode based on system preference */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --primary-color: #3b82f6;
        --secondary-color: #94a3b8;
        --success-color: #22c55e;
        --warning-color: #fbbf24;
        --error-color: #f87171;
        --background: #1e293b;
        --surface: #334155;
        --surface-hover: #475569;
        --border: #475569;
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --app-background: #0f172a;
        --loading-overlay-bg: rgba(15, 23, 42, 0.95);
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: var(--app-background);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#app {
    display: flex;
    height: 100vh;
    gap: var(--column-gap);
    padding: var(--column-gap);
    background: var(--app-background);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--background);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.sidebar-header .version {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem;
}

.nav-btn {
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.25rem;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--surface-hover);
}

.nav-btn.active {
    background: var(--primary-color);
    color: white;
}

.nav-btn .icon {
    font-size: 1.25rem;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--error-color);
}

.connection-status.connected .status-dot {
    background: var(--success-color);
}

/* Main Content - Middle Column */
.main-content {
    flex: 1;
    background: var(--background);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.content-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--background);
}

.content-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.content-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Tab buttons */
.results-tabs {
    display: flex;
    gap: 0.25rem;
    background: var(--surface);
    padding: 0.25rem;
    border-radius: 0.5rem;
}

.results-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.results-tab:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.results-tab.active {
    background: var(--background);
    color: var(--primary-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.content-body {
    flex: 1;
    padding: 0;
    overflow-y: auto;
    position: relative;
}

/* Tab content */
.results-tab-content {
    display: none;
    padding: 1.5rem;
    height: 100%;
    overflow-y: auto;
}

.results-tab-content.active {
    display: block;
    background: var(--background);
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 3rem 2rem;
}

.welcome-message h2 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.welcome-message p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.action-card {
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    background: var(--surface-hover);
}

.action-card .icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
}

.action-card h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.action-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Detailed view styles */
.detailed-issue-card,
.detailed-project-card {
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 1.5rem;
}

.issue-main,
.project-main {
    flex: 1;
}

.issue-sidebar,
.project-sidebar {
    padding: 1rem;
    background: var(--background);
    border-radius: 0.375rem;
}

.issue-field,
.project-field {
    margin-bottom: 1rem;
}

.issue-field label,
.project-field label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.issue-description,
.project-description {
    color: var(--text-secondary);
    margin-top: 0.75rem;
    line-height: 1.5;
}

.details-header {
    margin-bottom: 1.5rem;
}

.details-header h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

/* Raw data view */
.raw-data-container {
    height: 100%;
}

.raw-data-container h3 {
    font-size: 1.125rem;
    margin-bottom: 1rem;
}

.raw-data-content {
    background: var(--surface);
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Summary stats */
.summary-stats {
    display: flex;
    gap: 2rem;
    margin-top: 0.5rem;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Show more indicator */
.show-more {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 1rem;
    border-top: 1px solid var(--border);
    margin-top: 1rem;
}

/* Priority classes */
.priority-high {
    color: var(--error-color);
}

.priority-medium {
    color: var(--warning-color);
}

.priority-low {
    color: var(--success-color);
}

/* Status badge */
.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-todo {
    background: #e2e8f0;
    color: #475569;
}

.status-progress {
    background: #fef3c7;
    color: #92400e;
}

.status-done {
    background: #d1fae5;
    color: #064e3b;
}

/* Chat Pane - Right Column */
.chat-pane {
    width: var(--chat-width);
    background: var(--background);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--background);
    border-radius: 12px 12px 0 0;
}

.messages-container {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    background: var(--background);
}

.message {
    margin-bottom: 1.5rem;
    animation: fadeIn 0.3s;
}

.message-header {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.message.user .message-header {
    color: var(--primary-color);
}

.message-content {
    padding: 1rem;
    background: var(--surface);
    border-radius: 0.5rem;
    line-height: 1.6;
}

.message.user .message-content {
    background: var(--primary-color);
    color: white;
}

.input-container {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 1rem;
    background: var(--background);
    border-radius: 0 0 12px 12px;
}

.message-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    resize: none;
    font-family: inherit;
    font-size: 0.875rem;
    background: var(--surface);
}

.message-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.send-btn {
    padding: 0.75rem 2rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.send-btn:hover {
    background: #1d4ed8;
}

.send-btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
}

/* Send button spinner */
.btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Results Grid */
.results-grid {
    display: grid;
    gap: 1rem;
}

.result-item {
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: all 0.2s;
}

.result-item:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* Utilities */
.btn-secondary {
    padding: 0.5rem 1rem;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--surface-hover);
}

.btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 0.25rem;
    transition: background 0.2s;
    font-size: 1.25rem;
}

.btn-icon:hover {
    background: var(--surface-hover);
}

.loading {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.loading::after {
    content: '';
    display: inline-block;
    animation: ellipsis 1.4s infinite;
}

@keyframes ellipsis {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
    100% { content: ''; }
}

/* Alternative: Pulsing dots */
.typing .message-content {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing .loading {
    display: inline-flex;
    gap: 3px;
}

.typing .loading::before,
.typing .loading::after,
.typing .loading span {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: pulse 1.4s infinite ease-in-out;
}

.typing .loading::before {
    animation-delay: 0s;
}

.typing .loading span {
    animation-delay: 0.2s;
}

.typing .loading::after {
    animation-delay: 0.4s;
}

@keyframes pulse {
    0%, 60%, 100% {
        opacity: 0.4;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Issue Cards */
.issue-card {
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    transition: all 0.2s;
}

.issue-card:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transform: translateY(-1px);
    background: var(--surface-hover);
}

.issue-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.issue-key {
    font-weight: 600;
    color: var(--primary-color);
}

.issue-status {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--surface);
}

.issue-title {
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.issue-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Theme Toggle Button - Inline Version */
.theme-toggle-inline {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle-inline:hover {
    background: var(--surface-hover);
}

.theme-icon {
    color: var(--text-secondary);
    transition: opacity 0.3s ease;
}

.theme-icon.active {
    color: var(--primary-color);
}